package day7;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    /**
     * 给一个数n,求最少需要多少步可以变为fib数
     * 15   2
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        int count1 = 0;
        int count2 = 0;
        int num1 = n;
        int num2 = n;
        while (!isFib(num1)){
            num1--;
            count1++;
        }
        while (!isFib(num2)){
            num2++;
            count2++;
        }
        System.out.println(Math.min(count1,count2));
    }
    public static boolean isFib(int num){
        int num1 = 0;
        int num2 = 1;
        int end = 0;
        while (end < num){
            end = num2 + num1;
            num1 = num2;
            num2 = end;
            if (end == num){
                return true;
            }
        }
        return false;
    }
}